import instance from "./instance";
import { useCounterStore } from "../store";

import { ElMessage } from "element-plus";
export function getSendsms(phone) {
  return instance({
    method: "GET",
    url: "/server/login/sendsms",
    params: {
      phone,
      t: "login",
    },
  });
}
export function getDxlogin(code, phone) {
  return instance({
    method: "post",
    url: '/server/login/dxlogin',
    // url: "/server/login/testdxlogin", //测试数据
    data: {
      code,
      phone,
      devicetype: "",
      devicecode: "",
      shangji: "",
      source: 1,
    },
  });
}
export function getRooms(jwt) {
  return instance({
    method: "get",
    url: "/server/live/getfamilyroomlist",
    params: {
      jwt,
    },
  });
}
export function getTokenByRoomId({ jwt, roomid,targetuid='',type }) {
  return instance({
    method: "get",
    url: "/server/live/getliveshowtoken",
    params: {
      jwt,
      roomid,
      targetuid,//自己的可不传，别人的需要传
      type
    },
  });
}
export function getPaihang({ roomid, type, type1, page, limit, jwt }) {
  return instance({
    method: "get",
    url: "/server/index/getpaihang",
    params: {
      roomid,
      type,
      type1,
      page,
      limit,
      jwt,
    },
  });
}
// 获取房间信息
export function getmyliveroom(jwt) {
  return instance({
    method: "get",
    url: "/server/live/getmyliveroom",
    params: {
      cat: 2,
      jwt,
    },
  });
}
export function getuserinfo({ userid, jwt, look = 1 }) {
  return instance({
    method: "get",
    url: "/server/index/getuserinfo",
    params: {
      userid,
      jwt,
      look,
    },
  });
}
export function getFollow({ followuid, jwt }) {
  return instance({
    method: "get",
    url: "/server/index/follow",
    params: {
      followuid,
      jwt,
    },
  });
}
export function getUnFollow({ followuid, jwt }) {
  return instance({
    method: "get",
    url: "/server/index/unfollow",
    params: {
      followuid,
      jwt,
    },
  });
}
// 举报 
export function getReportApi(data) {
  return instance({
    method: "post",
    url: "/server/index/jubao",
    data,
  });
}


// 礼物列表
export function giftListApi({ uid, fenlei, jwt }) {
  return instance({
    method: "get",
    url: "/server/live/giftlist",
    params: {
      uid,
      fenlei,
      jwt,
    },
  });
}
// 礼物列表中的背包列表
export function getmybeibaoApi({ uid, jwt }) {
  return instance({
    method: "get",
    url: "/server/live/getmybeibao",
    params: {
      uid,
      jwt,
    },
  });
}
// 私聊记录列表
export function getchatlist({ touid, uid, jwt }) {
  return instance({
    method: "get",
    url: "/server/index/getchatlist",
    params: {
      touid,
      uid,
      jwt,
    },
  });
}
// 上传到阿里云前拿数据
export function getUploadMsg(type,suffix) {
  return instance({
    method: "get",
    url: `/server/admin/getosstoken?type=${type}&suffix=${suffix}`,
  });
}
// 弹出信息
export function $TipMessage(message, type) {
  ElMessage({
    message,
    type,
  });
}


// 清理数据的方法
export function deletData(jwt) {
  console.log('----------清理数据的方法-----------');
  return instance({
    method: "get",
    url: "server/live/testDelPkData",
    params: {
      jwt,
    },
  });
}
